package com.itheima.demo.demo03.demo04.CeShi;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Test_1 {
    public static void main(String[] args) {
        //一、请使用Map集合存储自定义数据类型Car做键，
        // 对应的价格做值。并使用keySet和entrySet两种方式遍历Map集合。


        Map<Car,Integer>map=new HashMap<>();
        map.put(new Car("马自达"),60000);
        map.put(new Car("别克英朗"),160000);
        map.put(new Car("宝马"),660000);
        Set<Map.Entry<Car, Integer>> entries = map.entrySet();
        for (Map.Entry<Car, Integer> entry : entries) {
            Car key = entry.getKey();
            Integer value = entry.getValue();
            System.out.println(key+" "+value);
        }

        Set<Car> cars = map.keySet();
        for (Car car : cars) {
            Integer price = map.get(car);
            System.out.print(price+" ");


        }



    }
}


